package com.sc.nft.service;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.sc.nft.dto.EcologyPoolIncreasePointsDTO;
import com.sc.nft.dto.EcologyPoolReducePointsDTO;
import com.sc.nft.entity.EcologyPool;
import com.sc.nft.entity.UserInfo;
import com.sc.nft.entity.dto.EcologyPoolExcellentBrandBatchAllocatePointsDaoDTO;
import com.sc.nft.entity.req.*;
import com.sc.nft.entity.vo.EcologyPoolGetPoolNameByDaoIdVo;
import com.sc.nft.entity.vo.EcologyPoolHatchCollectionVo;
import com.sc.nft.entity.vo.UserCreatorInfoExcelVO;
import com.sc.nft.entity.vo.ecologypool.*;
import com.sc.nft.enums.*;

import java.math.BigDecimal;
import java.util.Date;
import java.util.List;
import java.util.Map;

/**
 * @author 刘国航
 * @since 2024/7/15
 */
public interface EcologyPoolService {

    /**
     * 获取品牌池积分
     */
    EcologyPool getDaoPool(Long daoId);

    /**
     * 获取模板下载数据
     *
     * @return
     */
    List<UserCreatorInfoExcelVO> excellentBrandDownloadTemplate();

    /**
     * 优秀品牌池批量分配流水
     *
     * @param typeEnum 操作类型 生态分配/扣除
     * @param remark   备注
     * @param dtos     操作数据
     */
    void excellentBrandBatchAllocatePoints(EcologyPoolOperationTypeEnum typeEnum, String remark, List<EcologyPoolExcellentBrandBatchAllocatePointsDaoDTO> dtos) throws InterruptedException;

    /**
     * 根据生态池类型获取生态池积分
     *
     * @param ids
     * @return
     */
    Map<Long, EcologyPool> getDaoByIdsToMap(List<Long> ids);

    /**
     * 获取生态熔炼积分
     *
     * @param pageNo
     * @param pageSize
     * @return
     */
    Page<EcologyPoolSourceDayPageVO> sourceDayPage(Integer pageNo, Integer pageSize);

    /**
     * 获取生态熔炼积分-积分明细
     *
     * @param pageNo
     * @param pageSize
     * @param linkDate
     * @return
     */
    Page<EcologyPoolSourceDetailVO> sourceDetailPage(Integer pageNo, Integer pageSize, Date linkDate);

    /**
     * 查询积分明细
     *
     * @param pageNo
     * @param pageSize
     * @param userTel
     * @param collectionName
     * @param status
     * @param startTime
     * @param endTime
     * @return
     */
    Page<EcologyPoolSourceVO> sourcePage(Integer pageNo, Integer pageSize, String userTel, String collectionName, EcologyPoolSourceStatusEnum status, Date startTime, Date endTime);

    /**
     * 生态流水
     *
     * @param pageNo
     * @param pageSize
     * @param poolType
     * @param flowType
     * @param startTime
     * @param endTime
     * @return
     */
    Page<EcologyPoolRecordVO> recordPage(Integer pageNo, Integer pageSize, EcologyPoolTypeEnum poolType, EcologyPoolFlowTypeEnum flowType, Date startTime, Date endTime, String daoName);

    /**
     * 官方生态池分配/扣除积分
     *
     * @param operationType
     * @param excellentBrandCount
     * @param serviceCenterCount
     * @param communityNetworkCount
     * @param linkType
     * @param remark
     * @return
     */
    Boolean officialAllocatePoints(EcologyPoolOperationTypeEnum operationType, Long excellentBrandCount, Long serviceCenterCount, Long communityNetworkCount, EcologyPoolLinkTypeEnum linkType, String remark);

    /**
     * 优秀品牌池分配/扣除流水
     *
     * @param operationType
     * @param daoId
     * @param linkCount
     * @param linkType
     * @param remark
     * @return
     */
    Boolean excellentBrandAllocatePoints(EcologyPoolOperationTypeEnum operationType, Long daoId, Long linkCount, EcologyPoolLinkTypeEnum linkType, String remark);

    /**
     * 按品牌查询品牌生态池积分
     *
     * @param daoId
     * @param linkType
     * @return
     */
    EcologyPoolFindPointsByDaoVO findPointsByDao(Long daoId, EcologyPoolLinkTypeEnum linkType);

    /**
     * 查询已开启入榜的品牌
     *
     * @return
     */
    List<EcologyPoolGetEnableJoinRankDaoPageVo> getEnableJoinRankDaos();

    /**
     * 查询已生态池的品牌
     *
     * @return
     */
    List<EcologyPoolGetEnableJoinRankDaoPageVo> getEnableEcologyPools();

    /**
     * 排行榜查询
     *
     * @param pageNo
     * @param pageSize
     * @param rankName
     * @return
     */
    Page<EcologyPoolCommunityServiceRankConfVO> communityServiceRankConfPage(Integer pageNo, Integer pageSize, String rankName);

    /**
     * 新增排行榜
     *
     * @param request
     * @return
     */
    Boolean createCommunityServiceRankConf(EcologyPoolCreateCommunityServiceRankConfRequest request);

    /**
     * 获取榜单最大结束时间
     *
     * @param request
     * @return
     */
    EcologyPoolMaxCommunityServiceRankEndTimeVo getMaxCommunityServiceRankEndTime(EcologyPoolMaxCommunityServiceRankEndTimeRequest request);

    /**
     * 编辑排行榜
     *
     * @param id
     * @param activityRule
     * @return
     */
    Boolean updateCommunityServiceRankConf(Long id, String activityRule, String topImage);

    /**
     * 排行榜上下架
     *
     * @param id
     * @param status
     * @return
     */
    Boolean updateCommunityServiceRankConfStatus(Long id, Boolean status);

    /**
     * 删除排行榜-玛特DAO
     *
     * @param id
     * @return
     */
    Boolean deleteCommunityServiceRankConf(Long id);

    /**
     * 删除排行榜-非玛特DAO
     *
     * @param id
     * @return
     */
    Boolean deleteDaoCommunityServiceRankConf(Long id);

    /**
     * 排行榜详情
     *
     * @param id
     * @return
     */
    EcologyPoolCommunityServiceRankConfDetailVO communityServiceRankConfDetail(Long id);

    /**
     * 排行榜榜单-数据详情
     *
     * @param pageNo
     * @param pageSize
     * @param id
     * @return
     */
    Page<EcologyPoolCommunityServiceRankVO> communityServiceRankPage(Integer pageNo, Integer pageSize, Long id);

    /**
     * 排行榜榜单-数据详情
     *
     * @param pageNo
     * @param pageSize
     * @param id
     * @return
     */
    Page<EcologyPoolDaoCommunityServiceRankVO> daoCommunityServiceRankPage(Integer pageNo, Integer pageSize, Long id);


    /**
     * 生态流水
     *
     * @param pageNo
     * @param pageSize
     * @param userTel
     * @param poolTypeList
     * @param flowType
     * @param startTime
     * @param endTime
     * @return
     */
    Page<EcologyPoolRecordRpcVO> recordPage(Integer pageNo, Integer pageSize, String userTel, List<EcologyPoolTypeEnum> poolTypeList, EcologyPoolFlowTypeEnum flowType, Date startTime, Date endTime, Long daoId);

    /**
     * 获取生态池积分
     *
     * @param daoId
     * @param typeList
     * @return
     */
    Map<EcologyPoolTypeEnum, EcologyPoolDataVO> getPoolData(List<EcologyPoolTypeEnum> typeList, Long daoId, UserInfo userInfo);

    /**
     * 社区网点/服务中心分配积分
     *
     * @param operationType
     * @param poolType
     * @param userId
     * @param linkCount
     * @param linkType
     * @param remark
     * @return
     */
    Boolean communityServiceCenterAllocatePoints(EcologyPoolOperationTypeEnum operationType, EcologyPoolTypeEnum poolType, Long userId, Long linkCount, EcologyPoolLinkTypeEnum linkType, String remark);

    /**
     * 批量分配积分
     *
     * @param request
     * @return
     */
    Boolean batchCommunityServiceCenterAllocatePoints(EcologyPoolBatchAllocatePointsRequest request);

    /**
     * 按手机号查询积分
     *
     * @param daoId
     * @param userTel
     * @param linkType
     * @return
     */
    EcologyPoolFindPointsByUserTelVO findPointsByUserTel(Long daoId, String userTel, EcologyPoolLinkTypeEnum linkType, EcologyPoolTypeEnum poolType);

    /**
     * 按手机号列表查询积分
     *
     * @param daoId
     * @param linkType
     * @param dataList
     * @return
     */
    EcologyPoolUserUploadVo findPointsByUserTelList(Long daoId, EcologyPoolLinkTypeEnum linkType, List<EcologyPoolUploadUserDataRpcRequest> dataList, EcologyPoolTypeEnum poolType);

    /**
     * 品牌贡献榜配置
     *
     * @return
     */
    EcologyPoolWebRankConfVO daoRankConf();

    /**
     * 历史品牌排行榜配置详情
     *
     * @param id
     * @return
     */
    EcologyPoolHistoryDaoRankConfVo historyDaoRankConfDetail(Long id);

    /**
     * 品牌贡献榜
     *
     * @param pageNo
     * @param pageSize
     * @return
     */
    IPage<EcologyPoolWebDaoRankVO> daoRankPage(Integer pageNo, Integer pageSize);

    /**
     * 流水记录
     *
     * @param pageNo
     * @param pageSize
     * @param poolType
     * @param daoId
     * @param userInfo
     * @return
     */
    Page<EcologyPoolWebRecordVO> webRecordPage(Integer pageNo, Integer pageSize, EcologyPoolTypeEnum poolType, Long daoId, UserInfo userInfo);

    /**
     * 优秀品牌历史排行榜
     *
     * @param pageNo
     * @param pageSize
     * @return
     */
    IPage<EcologyPoolWebHistoryDaoRankConfVO> historyDaoRankConfPage(Integer pageNo, Integer pageSize);

    /**
     * 历史排行榜详情
     *
     * @param pageNo
     * @param pageSize
     * @param id
     * @return
     */
    IPage<EcologyPoolWebHistoryRankVO> historyDaoRankPage(Integer pageNo, Integer pageSize, Long id);

    /**
     * 服务中心/社区网点排行榜
     *
     * @param rankType
     * @return
     */
    EcologyPoolWebRankConfVO communityServiceRankConf(EcologyPoolCommunityServiceRankTypeEnum rankType, Long daoId);

    /**
     * 历史服务中心/社区网点排行榜配置详情
     *
     * @param id
     * @return
     */
    EcologyPoolHistoryDaoRankConfVo historyCommunityServiceRankConfDetail(Long id);

    /**
     * 服务中心/社区网点排行榜-数据详情
     *
     * @param pageNo
     * @param pageSize
     * @param rankType
     * @return
     */
    IPage<EcologyPoolWebCommunityServiceRankVO> communityServiceRankPage(Integer pageNo, Integer pageSize, EcologyPoolCommunityServiceRankTypeEnum rankType, Long daoId);

    /**
     * 服务中心/社区网点历史排行榜
     *
     * @param pageNo
     * @param pageSize
     * @param rankType
     * @return
     */
    IPage<EcologyPoolWebHistoryCommunityServiceRankConfVO> historyCommunityServiceRankConfPage(Integer pageNo, Integer pageSize, EcologyPoolCommunityServiceRankTypeEnum rankType, Long daoId);

    /**
     * 服务中心/社区网点历史排行榜-数据详情
     *
     * @param pageNo
     * @param pageSize
     * @param id
     * @return
     */
    IPage<EcologyPoolWebCommunityServiceRankVO> historyCommunityServiceRankPage(Integer pageNo, Integer pageSize, Long id);

    /**
     * 所属服务中心/社区网点排名
     *
     * @param rankType
     * @param user
     * @return
     */
    EcologyPoolWebMyCommunityServiceRankVO myCommunityServiceRank(EcologyPoolCommunityServiceRankTypeEnum rankType, UserInfo user, Long daoId);

    /**
     * 增加生态池积分
     */
    void increasePoints(EcologyPoolIncreasePointsDTO ecologyPoolIncreasePointsDTO);

    /**
     * 减少生态池积分
     */
    void reducePoints(EcologyPoolReducePointsDTO ecologyPoolReducePointsDTO);

    /**
     * 更新生态池名称
     *
     * @param id
     * @param daoId
     * @param poolName
     * @return
     */
    Boolean updatePoolName(Long id, Long daoId, String poolName);

    /**
     * 创建排行榜-非玛特DAO
     *
     * @param request
     * @return
     */
    Boolean createDaoCommunityServiceRankConf(EcologyPoolCreateDaoCommunityServiceRankConfRpcRequest request);

    /**
     * 获取熔炼藏品
     *
     * @param daoId
     * @return
     */
    List<EcologyPoolHatchCollectionVo> hatchCollectionList(String collectionName, Long daoId);

    /**
     * 根据品牌获取生态池积分名称
     *
     * @param daoId
     * @return
     */
    EcologyPoolGetPoolNameByDaoIdVo getPoolNameByDaoId(Long daoId);

    /**
     * 排行版详情-非玛特DAO
     *
     * @param id
     * @return
     */
    EcologyPoolDaoCommunityServiceRankConfDetailVo daoCommunityServiceRankConfDetail(Long id);

    /**
     * 排行榜查询-非玛特DAO
     *
     * @param pageNo
     * @param pageSize
     * @param rankName
     * @param daoId
     * @param approvalStatus
     * @return
     */
    Page<EcologyPoolDaoCommunityServiceRankConfVo> daoCommunityServiceRankConfPage(Integer pageNo, Integer pageSize, String rankName, EcologyPoolCommunityServiceRankApprovalStatusEnum approvalStatus, Long daoId);

    /**
     * 榜单奖励分页
     *
     * @param id
     * @return
     */
    List<EcologyPoolCommunityServiceRankPrizeVo> communityServiceRankPrize(Long id);

    /**
     * 服务中心/社区网点排行榜分页-非玛特DAO
     *
     * @param pageNo
     * @param pageSize
     * @param rankName
     * @param daoId
     * @param approvalStatus
     * @return
     */
    Page<EcologyPoolDaoCommunityServiceRankConfVo> daoCommunityServiceRankConfPage(Integer pageNo, Integer pageSize, String rankName, Long daoId, EcologyPoolCommunityServiceRankApprovalStatusEnum approvalStatus);

    /**
     * 排行榜审核
     *
     * @param id
     * @param approvalStatus
     * @return
     */
    Boolean daoCommunityServiceRankConfApproval(Long id, EcologyPoolCommunityServiceRankApprovalStatusEnum approvalStatus, String approvalMessage);

    /**
     * 兑换生态积分
     *
     * @param linkCount
     * @param daoId
     * @param userId
     */
    void convertPoints(BigDecimal linkCount, Long daoId, Long userId);

}

